#include "MouseState.h"
#include "Common.h"

MouseState::MouseState()
{
	m_nButtonFlags = 0x00000000;
	m_nWheel = 0;
}

MouseState::~MouseState()
{
}

MouseState MouseState::GetState()
{
	MouseState mouseState;

	for(int a = 0; a < GLFW_MOUSE_BUTTON_LAST; a++)
	{
		if(glfwGetMouseButton(a) == GL_TRUE)
		{
			mouseState.m_nButtonFlags |= (int)pow(2.0f, (float)a);
		}
	}
	
	glfwGetMousePos(&mouseState.m_vPosition.X, &mouseState.m_vPosition.Y);

	mouseState.m_nWheel = glfwGetMouseWheel();

	return mouseState;
}



const Vector2i MouseState::GetPosition() const
{
	return m_vPosition;
}

const int MouseState::GetWheel() const
{
	return m_nWheel;
}

const bool MouseState::IsButtonDown(MouseButtons button) const
{
	return (m_nButtonFlags & button) == button;
}

const bool MouseState::IsButtonUp(MouseButtons button) const
{
	return (m_nButtonFlags & button) == 0;
}